package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

public class RecipeTest extends TestCase {

	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;
	
	protected void setUp() throws Exception {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Recipe 1");
		r1.setPrice(1);
		r1.setAmtCoffee(2);
		r1.setAmtMilk(1);
		r1.setAmtSugar(2);
		r1.setAmtChocolate(1);
	}

	protected void tearDown() throws Exception {
		cm = null;
		i = null;
		r1 = null;
	}
	//Testing getcoffeeamt
	public void testGetAmtCoffee() {
		assertEquals(6, r1.getAmtCoffee());
	}

	 
	 // Testing setAmtCoffee
	//should not accept negative 
	public void testSetAmtCoffee2() {
		r1.setAmtCoffee(-5);
		assertEquals(0, r1.getAmtCoffee());
	}

	public void testSetAmtCoffee3() {
		r1.setAmtCoffee(0);
		assertEquals(0, r1.getAmtCoffee());
	}
	 
	public void testSetAmtCoffee1() {
		r1.setAmtCoffee(5);
		assertEquals(5, r1.getAmtCoffee());
	} 
	 //Testing getmilkamt
	 
	
	public void testGetAmtMilk() {
		assertEquals(1, r1.getAmtMilk());
	}

	 
	//Testimg setAmtCoffee
	
	public void testSetAmtMilk1() {
		r1.setAmtMilk(2);
		assertEquals(2, r1.getAmtMilk());
	}

	public void testSetAmtMilk2() {
		r1.setAmtMilk(-2);
		assertEquals(0, r1.getAmtMilk());
	}

	public void testSetAmtMilk3() {
		r1.setAmtMilk(0);
		assertEquals(0, r1.getAmtMilk());
	}
	
	 //Testing getAmtChocoloate
	 
	public void testGetAmtChocolate() {
		assertEquals(1, r1.getAmtChocolate());
	}

	public void testSetAmtChocolate1() {
		r1.setAmtChocolate(2);
		assertEquals(2, r1.getAmtChocolate());
	}

	public void testSetAmtChocolate2() {
		r1.setAmtChocolate(-1);
		assertEquals(0, r1.getAmtChocolate());
	}
	
	public void testSetAmtChocolate3() {
		r1.setAmtChocolate(0);
		assertEquals(0, r1.getAmtChocolate());
	}
	public void testGetAmtSugar() {
		assertEquals(1, r1.getAmtSugar());
	}

	 
	// Test setamtsugar
	
	public void testSetAmtSugar1() {
		r1.setAmtSugar(15);
		assertEquals(15, r1.getAmtSugar());
	}

	public void testSetAmtSugar2() {
		r1.setAmtSugar(-2);
		assertEquals(0, r1.getAmtSugar());
	}
	public void testSetAmtSugar3() {
		r1.setAmtSugar(0);
		assertEquals(0, r1.getAmtSugar());
	}

	
	//Testing getName
	 
	public void testGetName() {
		assertEquals("Recipe 1", r1.getName());
	}

	//Testing Setname
	public void testSetName1() throws Exception {
		r1.setName("Lattee");
		assertEquals("Lattee", r1.getName());
	}
	//Testing getPrice
	
	public void testSetPrice2() {
		r1.setPrice(-30);
		assertEquals(0, r1.getPrice());
	}

	public void testGetPrice() {
		assertEquals(1, r1.getPrice());
	}

	public void testSetPrice1() {
		r1.setPrice(10);
		assertEquals(10, r1.getPrice());
	}
	
	public void testSetPrice3() {
		r1.setPrice(0);
		assertEquals(0, r1.getPrice());
	}
	//Testing correct recipe
	public void testEqualsRecipe1() {
		Recipe r2 = new Recipe();
		r2.setName("Recipe 1");
		r2.setPrice(1);
		r2.setAmtCoffee(2);
		r2.setAmtMilk(1);
		r2.setAmtSugar(2);
		r2.setAmtChocolate(1);
		
		assertTrue(r1.equals(r2));
	}
	
	public void testEqualsRecipe2() {
		Recipe r2 = new Recipe();
		r2.setName("Recipe 2");
		r2.setPrice(1);
		r2.setAmtCoffee(2);
		r2.setAmtMilk(1);
		r2.setAmtSugar(2);
		r2.setAmtChocolate(1);
		
		assertFalse(r1.equals(r2));
	}

	public void testToString() {
		assertEquals("Coffee", r1.toString());
	}

}
